import { s_getcommontableinfo, s_getProduceInfo, status2text } from "@/services/basis";
import { ProCard, ProColumns, ProTable } from "@ant-design/pro-components";
import { Button,Image } from "antd";
import { useState } from "react";

const App:React.FC=()=>{
  const [total,setTotal]=useState(0);
  const [tdata,setTdata]=useState([]);
  interface DataType{
//     x_id,id,org_id,operate_time,status ,vouch_code,
// source_type,source_mid,material_id,userdefine_name,quantity,begindate,enddate,priority,
// quantity_alloc,quantity_alloc_begin,quantity_done,quantity_done_bad,
// code,name,invstd,invstd2,munit_name,pic,
//  sale_vouch_code, custom_name
 rid?:number,
 x_id?:number,id?:number,org_id?:number,operate_time?:string,status?:number ,vouch_code?:string,
source_type?:number,source_mid?:number,material_id?:number,userdefine_name?:string,quantity?:number,
begindate?:string,enddate?:string,priority?:number,
quantity_alloc?:number,quantity_alloc_begin?:number,quantity_done?:number,quantity_done_bad?:number,
code?:string,name?:string,invstd?:string,invstd2?:string,munit_name?:string,pic?:string,
 sale_vouch_code?:string, custom_name?:string,progress_done?:number,progress_alloc?:number,
 };

 const columns:ProColumns<DataType>[]=[
  {dataIndex:'rid',hidden:true,search:false},
  {dataIndex:'pic',title:'图片',width:80,search:false,
  //   render:(text)=>{
  //       var pic=text=="-"||text==undefined?"":"/basis_api/file/get?filename="+text;
  //       return <Image src={pic} style={{width:50,height:50}} alt='无' />
  //       },
  //  },
   render:(text,record,index,k)=>{
                     var pic="/basis_api/file/get2?filename="+record.code;
                     return   <Image src={pic}  style={{width:50,height:50}} alt='无' />
       }},
  {dataIndex:'custom_name',title:'店铺',width:120},
  {dataIndex:'vouch_code',title:'生产单号',width:100},
  {dataIndex:'operate_time',title:'下单日期',valueType:'date',width:100},
  {dataIndex:'code',title:'SKU编码',search:false},
  {dataIndex:'name',title:'名称',width:100},
  {dataIndex:'invstd',title:'包装规格',search:false},
  {dataIndex:'invstd2',title:'型号',search:false},
  // {dataIndex:'userdefine_name',title:'自定义项'},
  {dataIndex:'munit_name',title:'单位',search:false},
  {dataIndex:'quantity',title:'下单数量',search:false},
  {dataIndex:'quantity_alloc',title:'派工数量',search:false},
  {dataIndex:'progress_alloc',title:'派工比例',valueType:'progress',search:false},
  {dataIndex:'quantity_done',title:'完工数量',search:false},
  {dataIndex:'progress_done',title:'完工比例',valueType:'progress',search:false},
  {dataIndex:'quantity_done_bad',title:'不良数量',search:false},
  {dataIndex:'sale_vouch_code',title:'销售单号',search:false},
  
  {dataIndex:'status',title:'状态',valueType:'select',width:80,
            valueEnum:{1:{text:'未审核'},5:{text:'已审核'},
            6:{text:'已弃审'},2:{text:'关闭'},3:{text:'删除'},9:{text:'全部'}}
        },
 ];
   
  return <>
       <ProCard title='生产进度报表' style={{height:'85vh',overflow:'auto'}}>
           {/* {JSON.stringify(tdata)} */}
          <ProTable<DataType>
            columns={columns}
            search={{span:5}}
            options={false}
            rowKey='rid'
            // request={async ()=>{
            //   const x=await s_getcommontableinfo({x_id:1,cate:[],id:0,source:'v_produce_order_progress'});
            //   return{
            //     data:x.data[0],
            //     success:true,
            //   }
            // }}
            request={async (param)=>{
                    const x=await s_getProduceInfo({source:'v_produce_order_progress',x_id:1,
                                  fdata:{id:0,param}});
                     setTotal(x.data[0][0].count);
                      // setTdata(x.data[1]);
                    //  alert(JSON.stringify(x.data[1]));
                      return {
                            data:x.data[1],
                            success:true,
                            }
                       }}
            scroll={{y:'50vh'}}
            pagination={{
                    showQuickJumper:true,
                    showSizeChanger:true,
                    defaultPageSize:10,
                    defaultCurrent:1,
                    total,
                  }}
            />

       </ProCard>
     </>
};

export default App;